<?php
/**
 * Represents a fily_Html submit button.
 */
fily_XMLConverter::registerNamespace('submit', fily_Submit);
class fily_Submit extends fily_Input {

    /**
     * validation group  for javascript validators
     * @var <type>
     */
    protected $validationGroup;

    /**
     * if the click event from the control should be validated
     * @var boolean
     */
    protected $validate = true;


    /**
     *
     */
    public function __construct() {
        parent::__construct();
        $this->attributes->set('type', 'submit');
        $this->setExecutionTime(200);
    }

    /**
     * prepares code for html output
     */
    public function prepare() {
        parent::prepare();
        if($this->getValidate()) {
            $code = sprintf("firelynx.SubmitButton('%s', '%s', %s);", $this->getId(), $this->getValidationGroup(),  $this->getExecutionTime());
            fily_ClientCodeManager::addCode($code);
            fily_ClientCodeManager::useId($this->getId());
        }
    }

    /**
     * sets the validation group
     * @param string $value
     */
    public function setValidationGroup($value) {
        $this->validationGroup = $value;
    }

    /**
     * returns the validation group
     * @return string
     */
    public function getValidationGroup() {
        return $this->validationGroup;
    }

    /**
     * sets if the click event from the control will be validated
     * @param boolean $value
     */
    public function setValidate($value) {
        $this->validate = $value;
    }

    /**
     * returns if the click event from the control will be validated
     * @return boolean
     */
    public function getValidate() {
        return $this->validate;
    }

     /**
     * execution time for the javascript code
     * @var int
     */
    protected $executionTime;

    /**
     * get the execution time for the javascript code
     * @return <type>
     */
    public function getExecutionTime() {
        return $this->executionTime;
    }

    /**
     *  set the execution time for the javascript code
     * @param <type> $executionZone
     */
    public function setExecutionTime($executionTime) {
        $this->executionTime = $executionTime;
    }
}


?>
